﻿module Sustainalytics.GCCS {

    export class GCAnalysisOfCompanyManagementController {

        // principle summary ID
        private principleSummaryId: string;

        // company - principle controller
        private companyPrincipleController: GCCompanyPrincipleController;

        // principle - event indicators managements
        public eventIndicatorManagements: GCPrincipleEventIndicatorManagementDto[];


        constructor(
            private $scope: ng.IScope,
            private $q: ng.IQService,
            private GCPrincipleEventIndicatorManagementService: IGCPrincipleEventIndicatorManagementService) {

            var ctx = this;
            $scope['gcAnalysisOfCompanyManagement'] = ctx;

            // get principle controller
            ctx.companyPrincipleController = $scope['gcCompanyPrinciple'];

            // current principle summary ID
            ctx.principleSummaryId = ctx.companyPrincipleController.companyPrinciple.id;


            ctx.getEventIndicatorsManagementInfo();
        }


        // get event indicators managements by principle summary ID
        public getEventIndicatorsManagementInfo(): ng.IPromise<GCPrincipleEventIndicatorManagementDto[]> {
            var ctx = this;

            var promise = ctx.GCPrincipleEventIndicatorManagementService.GetByPrincipleSummaryId(ctx.principleSummaryId);

            promise.then(function (data) {
                ctx.eventIndicatorManagements = data;
            });

            return promise;
        }
    }


    angular.module('Sustainalytics.GCCS').controller('GCAnalysisOfCompanyManagementController', GCAnalysisOfCompanyManagementController);
}